set more off
clear all

cls

*if =1 (default), then produce Figures 3, 4b. If =0, then produce Figures 8, 9
local few_countries_flag=0


local flag_USA=2 
use "../international_data/prices_by_country", replace


qui merge 1:1 country year using "../international_data/consumption_gdp"
qui drop _merge

qui merge 1:1 country year using "../international_data/total_economy_database"
qui drop _merge

qui merge 1:1 country year using "../international_data/labor_force"
qui drop _merge

qui merge 1:1 country year using "../international_data/population_final"
qui drop _merge

sort country year



qui keep if year>=1950 /*hours data start*/
qui keep if year<=2018 /*population data finishes*/


qui replace CPI_recreation_real=CPI_recreation_real2 if country=="USA" & `flag_USA'==2
qui replace CPI_all=CPI_all2 if country=="USA" & `flag_USA'==2
qui drop CPI_recreation_real2 CPI_all2

*make relevant stuff real
qui gen C_rec_real=fcons_rec_total/CPI_all_longer/CPI_recreation_real
qui gen C_nonrec_real=fcons_total/CPI_all_longer
qui gen Employee_compensation_real=femployee_compensation_current/CPI_all_longer
qui gen GDP_real=fGDP_current/CPI_all_longer

rename Population Population_TED
rename Hours_per_worker Hours_per_worker_TED

qui gen Population_working_age=(populationT_25_29+populationT_30_34+populationT_35_39+populationT_40_44+populationT_45_49+populationT_50_54+populationT_55_59+populationT_60_64)
qui gen Population_above_working_age = Population_working_age +populationT_65_69 +populationT_70_74 +populationT_75_79 +populationT_80_84 +populationT_85_OVER
qui gen Population_adult = populationT_20_24 + Population_working_age +populationT_65_69 +populationT_70_74
qui gen Population_total = Population_adult + populationT_0_4 + populationT_5_9 + populationT_10_14 + populationT_15_19 +populationT_75_79 +populationT_80_84 +populationT_85_OVER


*Set the population that is used to normalized variables
qui gen Population_denom = Population_adult
qui replace numberEmp_T_70_74=0 if numberEmp_T_70_74==.
qui replace numberEmp_T_65_69=0 if numberEmp_T_65_69==.
	
qui gen Employment_denom=numberEmp_T_20_24+numberEmp_T_25_64+numberEmp_T_65_69+numberEmp_T_70_74



qui gen Comp_real_per_hour=Employee_compensation_real/Hours
qui gen GDP_real_per_capita=GDP_real/Population_denom
qui gen GDP_real_per_hour=GDP_real/Hours
qui gen C_rec_real_per_capita=C_rec_real/Population_denom
qui gen C_nonrec_real_per_capita=C_nonrec_real/Population_denom

qui gen Hours_per_capita=Hours/Population_denom
qui gen Hours_per_worker=Hours/Employment_denom
qui gen Employed_per_capita=Employment_denom/Population_denom


replace numberPop_T_TOTAL=numberPop_T_TOTAL*10^3
replace Population_TED=Population_TED*10^3
replace numberPop_T_25_64=numberPop_T_25_64*10^3
replace Population_denom = Population_denom*10^3

		 
encode country, gen(country_ind)



********************************************************************************
****************************PLOTS***********************************************
********************************************************************************
bys country: egen N=sum(CPI_recreation_real!=.)
keep if N>=15
replace Hours_per_capita=Hours_per_capita*10^6
replace Hours_per_worker=Hours_per_worker*10^3

local flag_trend_tables=1


***AGGREGATE LINEAR TRENDS***
preserve
	gen l_hours_per_capita=log(Hours_per_capita)
	gen l_hours_per_worker=log(Hours_per_worker)
	gen l_CPI_recreation_real=log(CPI_recreation_real)
	gen l_rcompensation_per_hour=log(Comp_real_per_hour)

	reghdfe l_hours_per_capita year, absorb(country) vce(robust)
	reghdfe l_hours_per_worker year, absorb(country) vce(robust)
	reghdfe l_CPI_recreation_real year, absorb(country) vce(robust)
	reghdfe l_rcompensation_per_hour year, absorb(country) vce(robust)

restore




*Table 4
if `flag_trend_tables'==1 {

			save data_init, replace


			gen country_full=""
			replace country_full="Australia" if country=="AUS"
			replace country_full="Austria" if country=="AUT"
			replace country_full="Belgium" if country=="BEL"
			replace country_full="Brazil" if country=="BRA"
			replace country_full="Bulgaria" if country=="BGR"
			replace country_full="Canada" if country=="CAN"
			replace country_full="Chile" if country=="CHL"
			replace country_full="Colombia" if country=="COL"
			replace country_full="Costa Rica" if country=="CRI"
			replace country_full="Croatia" if country=="HRV"
			replace country_full="Cyprus" if country=="CYP"
			replace country_full="Czechia" if country=="CZE"
			replace country_full="Denmark" if country=="DNK"
			replace country_full="Estonia" if country=="EST"
			replace country_full="Finland" if country=="FIN"
			replace country_full="France" if country=="FRA"
			replace country_full="Germany" if country=="DEU"
			replace country_full="Greece" if country=="GRC"
			replace country_full="Hungary" if country=="HUN"
			replace country_full="Iceland" if country=="ISL"
			replace country_full="Ireland" if country=="IRL"
			replace country_full="Israel" if country=="ISR"
			replace country_full="Italy" if country=="ITA"
			replace country_full="Japan" if country=="JPN"
			replace country_full="Korea" if country=="KOR"
			replace country_full="Latvia" if country=="LVA"
			replace country_full="Lithuania" if country=="LTU"
			replace country_full="Luxembourg" if country=="LUX"
			replace country_full="North Macedonia" if country=="MKL"
			replace country_full="Malta" if country=="MLT"
			replace country_full="Mexico" if country=="MEX"
			replace country_full="Netherlands" if country=="NLD"
			replace country_full="New Zealand" if country=="NZL"
			replace country_full="Norway" if country=="NOR"
			replace country_full="Poland" if country=="POL"
			replace country_full="Portugal" if country=="PRT"
			replace country_full="Romania" if country=="ROU"
			replace country_full="Russia" if country=="RUS"
			replace country_full="Slovakia" if country=="SVK"
			replace country_full="Slovenia" if country=="SVN"
			replace country_full="Spain" if country=="ESP"
			replace country_full="Sweden" if country=="SWE"
			replace country_full="Switzerland" if country=="CHE"
			replace country_full="Turkey" if country=="TUR"
			replace country_full="United Kingdom" if country=="GBR"
			replace country_full="United States" if country=="USA"
			
			drop country
			rename country_full country
			
			sort country year


			save data_temp.dta, replace

			***country-by-country trends
			gen l_hours_per_capita=log(Hours_per_capita)
			preserve
				statsby n=e(N) _b _se e(df_r), by(country) clear: regress l_hours_per_capita year, vce(robust)
				gen low=_b_year+invttail(e(df_r),1-0.05)*_se_year
				gen high=_b_year+invttail(e(df_r),0.05)*_se_year
				gen sign_10=0
				replace sign_10=1 if low*high>0
				drop low high 
				gen low=_b_year+invttail(e(df_r),1-0.025)*_se_year
				gen high=_b_year+invttail(e(df_r),0.025)*_se_year
				gen sign_5=0 
				replace sign_5=1 if low*high>0
				drop low high 
				gen low=_b_year+invttail(e(df_r),1-0.005)*_se_year
				gen high=_b_year+invttail(e(df_r),0.005)*_se_year
				gen sign_1=0 
				replace sign_1=1 if low*high>0
				drop low high 
				rename _b_year gamma_h
				rename _eq2_n N_obs_hours
				egen sign_h=rowtotal(sign*)
				keep gamma* sign_h country*
				save gamma_hours, replace
			restore 
			sort country year
			keep if Hours_per_capita!=.
			sort country year
			by country: egen year_first_h=min(year)
			keep country year_first_h
			by country: gen id=_n
			drop if id>1
			drop id
			merge 1:1 country using gamma_hours
			drop _merge
			sleep 500
			save gamma_hours, replace
			
			
			use data_temp.dta, replace	
			gen l_hours_per_worker=log(Hours_per_worker)
			preserve
				statsby n=e(N) _b _se e(df_r), by(country) clear: regress l_hours_per_worker year, vce(robust)
				gen low=_b_year+invttail(e(df_r),1-0.05)*_se_year
				gen high=_b_year+invttail(e(df_r),0.05)*_se_year
				gen sign_10=0
				replace sign_10=1 if low*high>0
				drop low high 
				gen low=_b_year+invttail(e(df_r),1-0.025)*_se_year
				gen high=_b_year+invttail(e(df_r),0.025)*_se_year
				gen sign_5=0 
				replace sign_5=1 if low*high>0
				drop low high 
				gen low=_b_year+invttail(e(df_r),1-0.005)*_se_year
				gen high=_b_year+invttail(e(df_r),0.005)*_se_year
				gen sign_1=0 
				replace sign_1=1 if low*high>0
				drop low high 
				rename _b_year gamma_h_per_worker
				rename _eq2_n N_obs
				egen sign_h_per_worker=rowtotal(sign*)
				keep gamma* sign_h_per_worker country*
				save gamma_hours_per_worker, replace
			restore
			sort country year
			keep if Hours_per_worker!=.
			by country: egen year_first_h_per_worker=min(year)
			keep country year_first_h
			by country: gen id=_n
			drop if id>1
			drop id
			merge 1:1 country using gamma_hours_per_worker
			drop _merge
			sleep 500
			save gamma_hours_per_worker, replace


				
			
			
			
			use data_temp.dta, replace
			preserve
				gen l_rcompensation_per_hour=log(Comp_real_per_hour)
				statsby n=e(N) _b _se e(df_r), by(country) clear: regress l_rcompensation_per_hour year, vce(robust)
				gen low=_b_year+invttail(e(df_r),1-0.05)*_se_year
				gen high=_b_year+invttail(e(df_r),0.05)*_se_year
				gen sign_10=0
				replace sign_10=1 if low*high>0
				drop low high 
				gen low=_b_year+invttail(e(df_r),1-0.025)*_se_year
				gen high=_b_year+invttail(e(df_r),0.025)*_se_year
				gen sign_5=0 
				replace sign_5=1 if low*high>0
				drop low high 
				gen low=_b_year+invttail(e(df_r),1-0.005)*_se_year
				gen high=_b_year+invttail(e(df_r),0.005)*_se_year
				gen sign_1=0 
				replace sign_1=1 if low*high>0
				drop low high 
				rename _b_year gamma_w
				drop _b_cons 
				rename _eq2_n N_obs_wage
				egen sign_w=rowtotal(sign*)
				keep gamma* sign_w country*
				save gamma_wage, replace
			restore
			sort country year
			keep if Comp_real_per_hour!=.
			by country: egen year_first_w=min(year)
			keep country year_first_w
			by country: gen id=_n
			drop if id>1
			drop id
			merge 1:1 country using gamma_wage
			drop _merge
			sleep 500
			save gamma_wage, replace
			
			
			
			use data_temp.dta, replace
			preserve
				gen l_CPI_recreation_real=log(CPI_recreation_real)
				statsby n=e(N) _b _se e(df_r), by(country) clear: regress l_CPI_recreation_real year, vce(robust)
				gen low=_b_year+invttail(e(df_r),1-0.05)*_se_year
				gen high=_b_year+invttail(e(df_r),0.05)*_se_year
				gen sign_10=0
				replace sign_10=1 if low*high>0
				drop low high 
				gen low=_b_year+invttail(e(df_r),1-0.025)*_se_year
				gen high=_b_year+invttail(e(df_r),0.025)*_se_year
				gen sign_5=0 
				replace sign_5=1 if low*high>0
				drop low high 
				gen low=_b_year+invttail(e(df_r),1-0.005)*_se_year
				gen high=_b_year+invttail(e(df_r),0.005)*_se_year
				gen sign_1=0 
				replace sign_1=1 if low*high>0
				drop low high 
				rename _b_year gamma_p
				drop _b_cons 
				rename _eq2_n N_obs_price
				egen sign_p=rowtotal(sign*)
				keep gamma* sign_p country*
				save gamma_price, replace
			restore
			sort country year
			keep if CPI_recreation_real!=.
			by country: egen year_first_p=min(year)
			keep country year_first_p
			by country: gen id=_n
			drop if id>1
			drop id
			merge 1:1 country using gamma_price
			drop _merge
			sleep 500
			save gamma_price, replace	
			
			
			
			
			use gamma_price, clear
			
			merge 1:1 country using gamma_wage
			drop _merge
			merge 1:1 country using gamma_hours
			drop _merge
			merge 1:1 country using gamma_hours_per_worker
			drop _merge
			
			
			drop if year_first_p==.
			drop if year_first_w==.
			drop if year_first_h==.
			drop if year_first_h_per_worker==.
			
			replace gamma_w=gamma_w*100
			replace gamma_p=gamma_p*100
			replace gamma_h=gamma_h*100
			replace gamma_h_per_worker=gamma_h_per_worker*100
			format %20s country
			
			

			
			egen av_gamma_p=mean(gamma_p)
			egen av_gamma_h=mean(gamma_h)
			egen av_gamma_h_per_worker=mean(gamma_h_per_worker)
			egen av_gamma_w=mean(gamma_w)
		
			
			sleep 500
			erase gamma_price.dta
			erase gamma_hours.dta
			erase gamma_wage.dta
			erase gamma_hours_per_worker.dta
			
			save trends_output, replace

			erase data_temp.dta
			
			use data_init.dta, clear

}





local N_drop=4
local norm_flag=0

preserve
	keep year country country_ind Hours_per_capita Hours
	bys year: egen N=total(Hours_per_capita!=.)
	if `norm_flag'==1{
		gen byte tag=1 if year==1950
		sort country tag
		by country: gen Hours_per_capita_norm=Hours_per_capita/Hours_per_capita[1]
		drop tag
		sort country year
		qui reg Hours_per_capita_norm i.year i.country_ind [pweight=Hours]
	}
	if `norm_flag'==0{
		qui reg Hours_per_capita i.year i.country_ind [pweight=Hours]
	}
	predict Hours_per_capita_pred
	if `norm_flag'==0{
		sort year
		by year: egen tot_hours=total(Hours*(Hours_per_capita!=.))
		by year: egen tot_hours_per_capita=total(Hours*Hours_per_capita)
		gen w=tot_hours_per_capita/tot_hours
	}
	keep if country=="AUS" /*first country, zero country FE*/
	if `norm_flag'==0{
		gen byte tag=1 if year==2015
		sort tag
		gen aux=Hours_per_capita_pred*w[1]/Hours_per_capita_pred[1]
		sort year
		drop Hours_per_capita_pred
		rename aux Hours_per_capita_pred
	}
	replace Hours_per_capita_pred=. if N<`N_drop'
	keep year Hours_per_capita_pred
	save TEMP_hours_per_capita_pred, replace
restore	



preserve
	keep year country country_ind Hours_per_worker Hours
	bys year: egen N=total(Hours_per_worker!=.)
	if `norm_flag'==1{
		gen byte tag=1 if year==2010
		sort country tag
		by country: gen Hours_per_worker_norm=Hours_per_worker/Hours_per_worker[1]
		drop tag
		sort country year
		qui reg Hours_per_worker_norm i.year i.country_ind [pweight=Hours]
	}
	if `norm_flag'==0{
		qui reg Hours_per_worker i.year i.country_ind [pweight=Hours]
	}
	predict Hours_per_worker_pred
	if `norm_flag'==0{
		sort year
		by year: egen tot_hours=total(Hours*(Hours_per_worker!=.))
		by year: egen tot_hours_per_worker=total(Hours*Hours_per_worker)
		gen w=tot_hours_per_worker/tot_hours
	}
	keep if country=="AUS" /*first country, zero country FE*/
	if `norm_flag'==0{
		gen byte tag=1 if year==2015
		sort tag
		gen aux=Hours_per_worker_pred*w[1]/Hours_per_worker_pred[1]
		sort year
		drop Hours_per_worker_pred
		rename aux Hours_per_worker_pred
	}
	replace Hours_per_worker_pred=. if N<`N_drop'
	keep year Hours_per_worker_pred
	save TEMP_hours_per_worker_pred, replace
restore	


preserve
	keep year country country_ind CPI_recreation_real Hours
	bys year: egen N=total(CPI_recreation_real!=.)
	gen byte tag=1 if year==2010
	sort country tag
	by country: gen CPI_recreation_real_norm=CPI_recreation_real/CPI_recreation_real[1]
	drop tag
	sort country year
	qui reg CPI_recreation_real_norm i.year i.country_ind [pweight=Hours]
	predict CPI_recreation_real_pred
	keep if country=="AUS" /*first country, zero country FE*/
	replace CPI_recreation_real_pred=. if N<`N_drop'
	keep year CPI_recreation_real_pred
	save TEMP_CPI_recreation_real_pred, replace
restore	

preserve
	keep year country country_ind Comp_real_per_hour
	bys year: egen N=total(Comp_real_per_hour!=.)
	gen byte tag=1 if year==2010
	sort country tag
	by country: gen Comp_real_per_hour_norm=Comp_real_per_hour/Comp_real_per_hour[1]
	drop tag
	sort country year
	qui reg Comp_real_per_hour_norm i.year i.country_ind
	predict Comp_real_per_hour_pred
	keep if country=="AUS" /*first country, zero country FE*/
	replace Comp_real_per_hour_pred=. if N<`N_drop'
	keep year Comp_real_per_hour_pred
	save TEMP_Comp_real_per_hour_pred, replace
restore	


preserve
	keep year country country_ind fcons_rec_total fcons_total Hours
	gen rec_share=fcons_rec_total/fcons_total
	bys year: egen N=total(rec_share!=.)
	
	sort country year
	reg rec_share i.year i.country_ind [pweight=Hours]
	predict rec_share_pred
	
	sort year
	by year: egen tot_hours=total(Hours*(rec_share!=.))
	by year: egen tot_rec_share=total(Hours*rec_share)
	gen w=tot_rec_share/tot_hours
	
	keep if country=="AUS"

	
	gen byte tag=1 if year==2015
	sort tag
	gen aux=rec_share_pred*w[1]/rec_share_pred[1]
	sort year
	drop rec_share_pred
	rename aux rec_share_pred
	
	replace rec_share_pred=. if N<`N_drop'
	keep year rec_share_pred
	save TEMP_rec_share_pred, replace
restore	




preserve
	keep year country country_ind femployee_compensation_current fconsumption_total_longer Hours
	gen cons_share=fconsumption_total_longer/femployee_compensation_current
	bys year: egen N=total(cons_share!=.)
	
	sort country year
	qui reg cons_share i.year i.country_ind [pweight=Hours]
	predict cons_share_pred
	
	sort year
	by year: egen tot_hours=total(Hours*(cons_share!=.))
	by year: egen tot_cons_share=total(Hours*cons_share)
	gen w=tot_cons_share/tot_hours
	
	keep if country=="AUS"

	
	gen byte tag=1 if year==2015
	sort tag
	gen aux=cons_share_pred*w[1]/cons_share_pred[1]
	sort year
	drop cons_share_pred
	rename aux cons_share_pred
	
	replace cons_share_pred=. if N<`N_drop'
	keep year cons_share_pred
	save TEMP_cons_share_pred, replace
restore	


preserve
	keep year country country_ind fGDP_current fconsumption_total_longer Hours
	gen cons_share_alt=fconsumption_total_longer/fGDP_current
	bys year: egen N=total(cons_share_alt!=.)
	
	sort country year
	qui reg cons_share_alt i.year i.country_ind [pweight=Hours]
	predict cons_share_alt_pred
	sort year
	by year: egen tot_hours=total(Hours*(cons_share_alt!=.))
	by year: egen tot_cons_share_alt=total(Hours*cons_share_alt)
	gen w=tot_cons_share_alt/tot_hours
	
	keep if country=="AUS"

	
	gen byte tag=1 if year==2015
	sort tag
	gen aux=cons_share_alt_pred*w[1]/cons_share_alt_pred[1]
	sort year
	drop cons_share_alt_pred
	rename aux cons_share_alt_pred
	
	replace cons_share_alt_pred=. if N<`N_drop'
	keep year cons_share_alt_pred
	save TEMP_cons_share2_pred, replace
restore	


merge m:1 year using TEMP_hours_per_capita_pred
drop _merge
merge m:1 year using TEMP_hours_per_worker_pred
drop _merge
merge m:1 year using TEMP_CPI_recreation_real_pred
drop _merge
merge m:1 year using TEMP_Comp_real_per_hour_pred
drop _merge
merge m:1 year using TEMP_rec_share_pred
gen rec_share=fcons_rec_total/fcons_total
drop _merge
merge m:1 year using TEMP_cons_share_pred
gen cons_share=fconsumption_total_longer/femployee_compensation_current
drop _merge
merge m:1 year using TEMP_cons_share2_pred
gen cons_share_alt=fconsumption_total_longer/fGDP_current
drop _merge

sort country year




if `few_countries_flag'==1 {
	keep if country=="USA" || country=="FRA" || country=="DEU" || country=="JPN" || country=="GBR" || country=="CAN" || country=="SWE" || country=="AUS" 
	gen country1=""
	replace country1="USA" if country=="USA"
	replace country1="France" if country=="FRA"
	replace country1="Germany" if country=="DEU"
	replace country1="Japan" if country=="JPN"
	replace country1="UK" if country=="GBR"
	replace country1="Canada" if country=="CAN"
	replace country1="Sweden" if country=="SWE"
	replace country1="Australia" if country=="AUS"
	
	
	
	label variable Hours_per_capita_pred "Global"
	if `norm_flag'==1{	
		gen byte tag=1 if year==1950
		sort country tag
		by country: gen Hours_per_capita_norm=Hours_per_capita/Hours_per_capita[1]
		by country: gen Hours_per_capita_pred_norm=Hours_per_capita_pred/Hours_per_capita_pred[1]
		label variable Hours_per_capita_pred_norm "Global"
		drop tag
	}
	
	
	label variable Hours_per_worker_pred "Global"
	if `norm_flag'==1{		
		gen byte tag=1 if year==2010
		sort country tag
		by country: gen Hours_per_worker_norm=Hours_per_worker/Hours_per_worker[1]
		by country: gen Hours_per_worker_pred_norm=Hours_per_worker_pred/Hours_per_worker_pred[1]
		label variable Hours_per_worker_pred_norm "Global"
		drop tag
	}
	
	
	gen byte tag=1 if year==2010
	sort country tag
	by country: gen CPI_recreation_real_norm=CPI_recreation_real/CPI_recreation_real[1]
	by country: gen CPI_recreation_real_pred_norm=CPI_recreation_real_pred/CPI_recreation_real_pred[1]
	label variable CPI_recreation_real_pred "Global"
	label variable CPI_recreation_real_pred_norm "Global"
	drop tag
	
	
	gen byte tag=1 if year==2010
	sort country tag
	by country: gen Comp_real_per_hour_norm=Comp_real_per_hour/Comp_real_per_hour[1]
	by country: gen Comp_real_per_hour_pred_norm=Comp_real_per_hour_pred/Comp_real_per_hour_pred[1]
	label variable Comp_real_per_hour_pred "Global"
	label variable Comp_real_per_hour_pred_norm "Global"
	drop tag
	
	
	label variable rec_share_pred "Global"

	sort country year
	
	**HOURS PER CAPITA**
	separate Hours_per_capita, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line Hours_per_capita_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(position(11) ring(0) cols(3)) xlabel(1950[10]2020) ylabel(800[200]2200) xtitle("") ytitle("Annual hours")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/hours_by_country_selected.png", as(png) replace
	graph export "../figures/hours_by_country_selected.eps", as(eps) replace
	*black and white
	gen Hours_per_capita_bw=Hours_per_capita
	separate Hours_per_capita_bw, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line Hours_per_capita_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(position(11) ring(0) cols(3)) xlabel(1950[10]2020) ylabel(800[200]2200) xtitle("") ytitle("Annual hours")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/hours_by_country_selected_bw.png", as(png) replace
	graph export "../figures/hours_by_country_selected_bw.eps", as(eps) replace
		
	
	
	**HOURS PER WORKER**	{	
	separate Hours_per_worker, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line Hours_per_worker_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(1400[200]2800) xtitle("") ytitle("Annual hours")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/hours_per_worker_by_country_selected.png", as(png) replace
	graph export "../figures/hours_per_worker_by_country_selected.eps", as(eps) replace
	*black and white
	gen Hours_per_worker_bw=Hours_per_worker
	separate Hours_per_worker_bw, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line Hours_per_worker_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(1400[200]2800) xtitle("") ytitle("Annual hours")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/hours_per_worker_by_country_selected_bw.png", as(png) replace
	graph export "../figures/hours_per_worker_by_country_selected_bw.eps", as(eps) replace
	
	
	**RECREATION PRICE**	
	separate CPI_recreation_real_norm, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line CPI_recreation_real_pred_norm year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.8[0.2]1.8) xtitle("") ytitle("Recreation price index, 2010=1")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/recreation_price_real_by_country_selected.png", as(png) replace	
	graph export "../figures/recreation_price_real_by_country_selected.eps", as(eps) replace
	*black and white
	gen CPI_recreation_real_norm_bw=CPI_recreation_real_norm
	separate CPI_recreation_real_norm_bw, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line CPI_recreation_real_pred_norm year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.8[0.2]1.8) xtitle("") ytitle("Recreation price index, 2010=1")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/recreation_price_real_by_country_selected_bw.png", as(png) replace	
	graph export "../figures/recreation_price_real_by_country_selected_bw.eps", as(eps) replace		
	
	
	**COMPENSATION PER HOUR**	
	separate Comp_real_per_hour_norm, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line Comp_real_per_hour_pred_norm year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.0[0.2]1.2) xtitle("") ytitle("Employee compensation per hour index, 2010=1")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/real_wage_by_country_selected.png", as(png) replace
	graph export "../figures/real_wage_by_country_selected.eps", as(eps) replace
	*black and white
	gen Comp_real_per_hour_norm_bw=Comp_real_per_hour_norm
	separate Comp_real_per_hour_norm_bw, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line Comp_real_per_hour_pred_norm year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.0[0.2]1.2) xtitle("") ytitle("Employee compensation per hour index, 2010=1")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/real_wage_by_country_selected_bw.png", as(png) replace
	graph export "../figures/real_wage_by_country_selected_bw.eps", as(eps) replace
	
	
	
	**RECREATION CONSUMPTION SHARE**	
	separate rec_share, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line  rec_share_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(position(11) ring(0) cols(2)) xlabel(1950[10]2020) ylabel(0.0[0.05]0.2) xtitle("") ytitle("")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/frac_recreation_cons_by_country_selected.png", as(png) replace
	graph export "../figures/frac_recreation_cons_by_country_selected.eps", as(eps) replace
	*black and white
	gen rec_share_bw=rec_share
	separate rec_share_bw, by(country1) veryshortlabel 
	twoway (connected `r(varlist)' year,/*
	*/lpattern(solid dash dash_dot shortdash solid longdash solid solid) /*
	*/msymbol(p p p p s p x o)) /*
	*/(line  rec_share_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(position(11) ring(0) cols(2)) xlabel(1950[10]2020) ylabel(0.0[0.05]0.2) xtitle("") ytitle("")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/frac_recreation_cons_by_country_selected_bw.png", as(png) replace
	graph export "../figures/frac_recreation_cons_by_country_selected_bw.eps", as(eps) replace	
	
}


if `few_countries_flag'==0 {
	
	label variable Hours_per_capita_pred "Global"
	if `norm_flag'==1{	
		gen byte tag=1 if year==1950
		sort country tag
		by country: gen Hours_per_capita_norm=Hours_per_capita/Hours_per_capita[1]
		by country: gen Hours_per_capita_pred_norm=Hours_per_capita_pred/Hours_per_capita_pred[1]
		label variable Hours_per_capita_pred_norm "Global"
		drop tag
	}
	
	
	label variable Hours_per_worker_pred "Global"
	if `norm_flag'==1{		
		gen byte tag=1 if year==2010
		sort country tag
		by country: gen Hours_per_worker_norm=Hours_per_worker/Hours_per_worker[1]
		by country: gen Hours_per_worker_pred_norm=Hours_per_worker_pred/Hours_per_worker_pred[1]
		label variable Hours_per_worker_pred_norm "Global"
		drop tag
	}
	
	
	gen byte tag=1 if year==2010
	sort country tag
	by country: gen CPI_recreation_real_norm=CPI_recreation_real/CPI_recreation_real[1]
	by country: gen CPI_recreation_real_pred_norm=CPI_recreation_real_pred/CPI_recreation_real_pred[1]
	label variable CPI_recreation_real_pred "Global"
	label variable CPI_recreation_real_norm "Global"
	drop tag
	
	
	gen byte tag=1 if year==2010
	sort country tag
	by country: gen Comp_real_per_hour_norm=Comp_real_per_hour/Comp_real_per_hour[1]
	by country: gen Comp_real_per_hour_pred_norm=Comp_real_per_hour_pred/Comp_real_per_hour_pred[1]
	label variable Comp_real_per_hour_pred "Global"
	label variable Comp_real_per_hour_norm "Global"
	drop tag
	
	sort country year
	
	
	**HOURS PER CAPITA**
	separate Hours_per_capita, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line Hours_per_capita_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(800[200]2200) xtitle("") ytitle("Annual hours")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/hours_by_country.png", as(png) replace
	graph export "../figures/hours_by_country.eps", as(eps) replace
	*black and white
	gen Hours_per_capita_bw=Hours_per_capita
	separate Hours_per_capita_bw, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line Hours_per_capita_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(800[200]2200) xtitle("") ytitle("Annual hours")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/hours_by_country_bw.png", as(png) replace
	graph export "../figures/hours_by_country_bw.eps", as(eps) replace
	
	
	**HOURS PER WORKER**	
	separate Hours_per_worker, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line Hours_per_worker_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(1400[400]3400) xtitle("") ytitle("Annual hours")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/hours_per_worker_by_country.png", as(png) replace
	graph export "../figures/hours_per_worker_by_country.eps", as(eps) replace
	*black and white
	gen Hours_per_worker_bw=Hours_per_worker
	separate Hours_per_worker_bw, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line Hours_per_worker_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(1400[400]3400) xtitle("") ytitle("Annual hours")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/hours_per_worker_by_country_bw.png", as(png) replace
	graph export "../figures/hours_per_worker_by_country_bw.eps", as(eps) replace	
	
	**RECREATION PRICE**	
	separate CPI_recreation_real_norm, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line CPI_recreation_real_pred_norm year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.8[0.2]2) xtitle("") ytitle("Recreation price index, 2010=1")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/recreation_price_real_by_country.png", as(png) replace	
	graph export "../figures/recreation_price_real_by_country.eps", as(eps) replace	
	*black and white
	gen CPI_recreation_real_norm_bw=CPI_recreation_real_norm
	separate CPI_recreation_real_norm_bw, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line CPI_recreation_real_pred_norm year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.8[0.2]2) xtitle("") ytitle("Recreation price index, 2010=1")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/recreation_price_real_by_country_bw.png", as(png) replace	
	graph export "../figures/recreation_price_real_by_country_bw.eps", as(eps) replace		
	
	
	**COMPENSATION PER HOUR**	
	separate Comp_real_per_hour_norm, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line Comp_real_per_hour_pred_norm year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.0[0.4]2) xtitle("") ytitle("Employee compensation per hour index, 2010=1")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/real_wage_by_country.png", as(png) replace
	graph export "../figures/real_wage_by_country.eps", as(eps) replace
	*black and white
	gen Comp_real_per_hour_norm_bw=Comp_real_per_hour_norm
	separate Comp_real_per_hour_norm_bw, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line Comp_real_per_hour_pred_norm year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.0[0.4]2) xtitle("") ytitle("Employee compensation per hour index, 2010=1")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/real_wage_by_country_bw.png", as(png) replace
	graph export "../figures/real_wage_by_country_bw.eps", as(eps) replace	
	
	**RECREATION CONSUMPTION SHARE**	
	separate rec_share, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line rec_share_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.0[0.05]0.2) xtitle("") ytitle("")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4)
	graph export "../figures/frac_recreation_cons_by_country.png", as(png) replace
	graph export "../figures/frac_recreation_cons_by_country.eps", as(eps) replace
	*black and white
	gen rec_share_bw=rec_share
	separate rec_share_bw, by(country) veryshortlabel 
	twoway (line `r(varlist)' year) (line rec_share_pred year if country=="USA", lwidth(thick) lcolor(black)), /*
	*/leg(off) xlabel(1950[10]2020) ylabel(0.0[0.05]0.2) xtitle("") ytitle("")/*
	*/bgcolor(white) graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin)) xlabel(,grid nogextend gmax) ylabel(,grid nogextend gmin gmax) ysize(4) scheme(s1mono)
	graph export "../figures/frac_recreation_cons_by_country_bw.png", as(png) replace
	graph export "../figures/frac_recreation_cons_by_country_bw.eps", as(eps) replace	
	
	
	
}



erase TEMP_hours_per_capita_pred.dta
erase TEMP_hours_per_worker_pred.dta
erase TEMP_CPI_recreation_real_pred.dta
erase TEMP_Comp_real_per_hour_pred.dta
erase TEMP_cons_share_pred.dta
erase TEMP_cons_share2_pred.dta
erase TEMP_rec_share_pred.dta
erase data_init.dta

